The present invention relates to database queries, and, more specifically, to the maintenance of active database queries.
Database management systems make it possible for users to store and update large collections of information, while also supporting queries over that information. Ideally, queries return answers that reflect the most up-to-date data in the database. However, a long-running query or transaction may need to process data that other concurrent transactions are trying to update.
Several contemporary concurrency control techniques attempt to manage such conflicting updates. For example, lock-based techniques may be utilized to prevent multiple transactions from obtaining access to a conflicting data item by causing conflicting transactions to wait. Lock-based techniques occasionally need to abort transactions due to deadlocks, and can lead to long wait queues if there are frequently accessed data items. Other contemporary control techniques includes optimistic methods that check for conflicts only at the end of the transaction, and abort the transaction if conflicts are found, leading to much wasted work if conflicts are frequent. Multi-version timestamp based control techniques keep track of access timestamps for data items, and abort a transaction if the transaction needs to write a data item in a way that is inconsistent with the item's timestamps. Again, significant work may be wasted.
To make queries faster, a commonly used technique is to store derived information in the database to make the retrieval and/or computation over the data more efficient. One example of such derived information is a materialized view, in which the answer to a query (e.g., a sub-query) is explicitly stored in the database. If a later query can use this stored sub-query, then the later query may be answered faster than it would without the availability of the materialized view.